package card;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class CardDemo {
    private static final String[] types = {"♦", "♥", "♣", "♥"};
    public CardDemo() {

    }
    public static List<Card> buyCard() {
        List<Card> cardList = new ArrayList<>();
        for (int i = 0; i < types.length; i++) {
            for (int j = 1; j <= 13; j++) {
                cardList.add(new Card(types[i], j));
            }
        }
        return cardList;
    }
    public static void shuffleCard(List<Card> cardList) {
        Random random = new Random();
        for (int i = cardList.size() - 1; i > 0; i--) {
            int index = random.nextInt(i);
            swap(cardList, index, i);
        }
    }
    public static void swap(List<Card> cardList, int a, int b) {
        Card card = cardList.get(a);
        cardList.set(a, cardList.get(b));
        cardList.set(b, card);
    }
    public static void getCard(List<Card> cardList) {
        List<List<Card>> list = new ArrayList<>();
        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        list.add(hand1);
        list.add(hand2);
        list.add(hand3);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < list.size(); j++) {
                Card c = cardList.remove(0);
                list.get(j).add(c);
            }
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }
}
